-- chess
-- created by xinj
-- 冈布奥召唤棋子

return {
    fetchInitData = function(classId)
        -- 根据专属技能等级对属性加成
        local prop = PropM.combine(ME.user, "chess", 1);
        local level = PropM.apply(prop, 1);

        -- 生命、攻击系数
        local dbase = SummonM.query(classId, "dbase");
        local hpCoef = dbase["chess_hp"] or 0;
        local attackCoef = dbase["chess_attack"] or 0;

        -- 初始继承玩家50%属性，3级时生命值加成、4级时攻击力加成
        if level < 3 then
            hpCoef = 500;
        end
        if level < 4 then
            attackCoef = 500;
        end

        local maxHp = ME.user:queryAttrib("max_hp");
        local attack = ME.user:queryAttrib("attack");

        maxHp = math.modf(maxHp * hpCoef / 1000);
        attack = math.modf(attack * attackCoef / 1000);

        maxHp = math.max(maxHp, 1);
        attack = math.max(attack, 1);

        return {
            ["hp"] = maxHp,
            ["max_hp"] = maxHp,
            ["attack"] = attack,
        };
    end,
};
